package com.yida.gwj.scene.expend.controller;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yida.common.core.utils.poi.ExcelUtil;
import com.yida.common.core.web.controller.BaseController;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.common.log.annotation.Log;
import com.yida.common.log.enums.BusinessType;
import com.yida.common.security.annotation.RequiresPermissions;
import com.yida.gwj.scene.expend.domain.GwjSceneExpendBusinessLog;
import com.yida.gwj.scene.expend.service.IGwjSceneExpendBusinessLogService;

/**
 * 业务日志处理（线下支出）Controller
 * 
 * @author hmh
 * @date 2023-08-14
 */
@RestController
@RequestMapping("/log")
public class GwjSceneExpendBusinessLogController extends BaseController {
    @Autowired
    private IGwjSceneExpendBusinessLogService gwjSceneExpendBusinessLogService;

    /**
     * 查询签署意见（线下支出）列表
     */
    @RequiresPermissions("gwj:scene:expend:log:list")
    @GetMapping("/list")
    public TableDataInfo list(GwjSceneExpendBusinessLog gwjSceneExpendBusinessLog) {
        startPage();
        List<GwjSceneExpendBusinessLog> list = gwjSceneExpendBusinessLogService.selectGwjSceneExpendBusinessLogList(gwjSceneExpendBusinessLog);
        return getDataTable(list);
    }

    /**
     * 导出签署意见（线下支出）列表
     */
    @RequiresPermissions("gwj:scene:expend:log:export")
    @Log(title = "线下支出日志", businessType = BusinessType.EXPORT, systemName = "gwj")
    @PostMapping("/export")
    public void export(HttpServletResponse response, GwjSceneExpendBusinessLog gwjSceneExpendBusinessLog) {
        List<GwjSceneExpendBusinessLog> list = gwjSceneExpendBusinessLogService.selectGwjSceneExpendBusinessLogList(gwjSceneExpendBusinessLog);
        ExcelUtil<GwjSceneExpendBusinessLog> util = new ExcelUtil<GwjSceneExpendBusinessLog>(GwjSceneExpendBusinessLog.class);
        util.exportExcel(response, list, "签署意见（线下支出）数据");
    }

    /**
     * 获取日志（线下支出）详细信息
     */
    @RequiresPermissions("gwj:scene:expend:log:query")
    @GetMapping(value = "/{bizLogId}")
    public AjaxResult getInfo(@PathVariable("bizLogId") Long bizLogId) {
        return AjaxResult.success(gwjSceneExpendBusinessLogService.selectGwjSceneExpendBusinessLogByBizLogId(bizLogId));
    }

    /**
     * 新增日志（线下支出）
     */
    @RequiresPermissions("gwj:scene:expend:log:add")
    @Log(title = "线下支出日志", businessType = BusinessType.INSERT, systemName = "gwj")
    @PostMapping
    public AjaxResult add(@RequestBody GwjSceneExpendBusinessLog gwjSceneExpendBusinessLog) {
        return toAjax(gwjSceneExpendBusinessLogService.insertGwjSceneExpendBusinessLog(gwjSceneExpendBusinessLog));
    }

    /**
     * 修改日志（线下支出）
     */
    @RequiresPermissions("gwj:scene:expend:log:edit")
    @Log(title = "线下支出日志", businessType = BusinessType.UPDATE, systemName = "gwj")
    @PutMapping
    public AjaxResult edit(@RequestBody GwjSceneExpendBusinessLog gwjSceneExpendBusinessLog) {
        return toAjax(gwjSceneExpendBusinessLogService.updateGwjSceneExpendBusinessLog(gwjSceneExpendBusinessLog));
    }

    /**
     * 删除日志（线下支出）
     */
    @RequiresPermissions("gwj:scene:expend:log:remove")
    @Log(title = "线下支出日志", businessType = BusinessType.DELETE, systemName = "gwj")
    @DeleteMapping("/{bizLogIds}")
    public AjaxResult remove(@PathVariable Long[] bizLogIds) {
        return toAjax(gwjSceneExpendBusinessLogService.deleteGwjSceneExpendBusinessLogByBizLogIds(bizLogIds));
    }
}
